import { fileURLToPath, URL } from 'node:url'
import UnoCSS from 'unocss/vite'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import AutoExport from 'unplugin-auto-export/vite';
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import VueRouter from 'unplugin-vue-router/vite'
import { VueRouterAutoImports } from 'unplugin-vue-router'
import vueDevTools from 'vite-plugin-vue-devtools'
export default defineConfig({
  plugins: [
    vueDevTools(),
    VueRouter({
    }),
    vue(),
    vueJsx(),
    UnoCSS(),
    AutoExport({
      // path: ['src/hooks/*'],
      // ignore: ['**/node_modules/*'],
      // formatter: (filename, extname) => `export * from './${filename}'`
    }),
    AutoImport({
      resolvers: [ElementPlusResolver()],
      imports: [
        'vue',
         VueRouterAutoImports,
        '@vueuse/core',
        'pinia',
        {
          'axios': [
            // default imports
            ['default', 'axios'], // import { default as axios } from 'axios',
          ],
        }
      ],
      dirs: [
        './src/hooks',
        './src/stores'
      ],
      dts: './auto-imports.d.ts',
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})
